import pymysql

dbinfo={
    "host":"****",
    "user":"root",
    "password":"123456",
    "post":3310,
    "databse":"gllmysql"
}

class DbConnet():
    def __init__(self,dbinfo=dbinfo):
        self.db = pymysql.connect(
            cursorclass=pymysql.cursors.DictCursor,
            **dbinfo,
        )
        self.cursor = self.db.cursor()

    def select(self,sql):
        #查询
        self.cursor.execute(sql)
        result = self.cursor.fetchall()
        return result

    def excute(self,sql):
        #删除，修改，新增
        try:
            self.cursor.execute(sql)
            self.db.commit()
        except:
            self.db.rollback()

    def close(self):
        self.cursor.close()
        self.db.close()

if __name__ == '__main__':
    db = DbConnet()
    select_sql = "selecy * from gg where id = 1"
    result = db.select(select_sql)
    print(result)
    db.close()